package com.example.toolproject.demo.controller;

import com.example.toolproject.demo.aop.SystemControllerLog;
import com.example.toolproject.demo.util.ResultBean;
import com.example.toolproject.demo.util.VerificationVode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName CaptchaController
 * @Description TODO   验证码生成
 * @Author lvyongwei
 * @Date 2020-06-17 9:26
 **/
@Controller
@CrossOrigin
public class CaptchaController {

    /**
     * 验证码生成工具类
     */
    @Autowired
    private VerificationVode verificationVode;

    /**
     *生成验证码图片
     * @param request
     * @param response
     */
    @GetMapping("/captchaImage")
    @ResponseBody
    @SystemControllerLog(description = "验证码获取")
    public ResultBean getCode(HttpServletRequest request, HttpServletResponse response){
        ResultBean resultBean=verificationVode.getRegisterCode(response,request);
        return resultBean;
    }

}
